<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 在promise的then方法内返回新的promise对象，并改变状态
        new Promise((res, rej) => {
            res('ok')
        }).then(val => {
            console.log(val);
            return 123;
        }).then(val => {
            console.log(val);
            return new Promise((res, rej) => {
                rej('err');
            })
        }).then(val => {
            console.log(val);
        }).catch(rea => {
            console.log(rea);
        })
    </script>
</body>

</html>